﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vme="clr-namespace:Notoric.ViewModel.Elements.CWNotation;assembly=ViewModel"
                    xmlns:ts="clr-namespace:Notoric.View.Music.CWNotation.TemplateSelectors.CWNotation">

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="SingleBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Stroke="Black" StrokeThickness="0.03cm"/>
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="DoubleBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.03cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"/>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="0.015cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"/>
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="RepetitionOpenBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="0.03cm 0 0 0" Stroke="Black" StrokeThickness="0.08cm"
                  />
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="0.09cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"
                  x:Name="PART_ThinLine"
                  />
            <ItemsControl ItemsSource="{Binding Owner.Owner.RepetitionDots, Mode=OneWay}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Canvas>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLine, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding X, Mode=OneWay}" Margin="0.118cm 0 0 0"/>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLine, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding Y, Mode=OneWay}" Margin="0.118cm 0 0 0"/>
                        </Canvas>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="RepetitionCloseBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.12cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"
                  x:Name="PART_ThinLine"
                  />
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.03cm 0 0 0" Stroke="Black" StrokeThickness="0.08cm"
                  />
            <ItemsControl ItemsSource="{Binding Owner.Owner.RepetitionDots, Mode=OneWay}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Canvas>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLine, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding X, Mode=OneWay}" Margin="-0.374cm 0 0 0"/>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLine, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding Y, Mode=OneWay}" Margin="-0.374cm 0 0 0"/>
                        </Canvas>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="RepetitionBothBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.12cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"
                  x:Name="PART_ThinLineC"
                  />
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.03cm 0 0 0" Stroke="Black" StrokeThickness="0.08cm"
                  />
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="0.09cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"
                  x:Name="PART_ThinLineO"
                  />
            <ItemsControl ItemsSource="{Binding Owner.Owner.RepetitionDots, Mode=OneWay}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Canvas>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLineC, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding X, Mode=OneWay}" Margin="-0.374cm 0 0 0"/>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLineC, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding Y, Mode=OneWay}" Margin="-0.374cm 0 0 0"/>
                        </Canvas>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
            <ItemsControl ItemsSource="{Binding Owner.Owner.RepetitionDots, Mode=OneWay}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Canvas>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLineO, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding X, Mode=OneWay}" Margin="0.118cm 0 0 0"/>
                            <Ellipse Fill="Black" Height="0.058cm" Width="0.058cm" Canvas.Left="{Binding ElementName=PART_ThinLineO, Path=X1, Mode=OneWay}"
                                     Canvas.Top="{Binding Y, Mode=OneWay}" Margin="0.118cm 0 0 0"/>
                        </Canvas>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:BarlineSegment}" x:Key="FinalBarlineTemplate">
        <Canvas>
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.12cm 0 0 0" Stroke="Black" StrokeThickness="0.03cm"
                  />
            <Line X1="{Binding X, Mode=OneWay}" X2="{Binding X, Mode=OneWay}" Y1="{Binding Y1, Mode=OneWay}" Y2="{Binding Y2, Mode=OneWay}" 
                  Margin="-0.03cm 0 0 0" Stroke="Black" StrokeThickness="0.08cm"
                  />
        </Canvas>
    </DataTemplate>

    <DataTemplate DataType="{x:Type vme:Barline}">
        <DataTemplate.Resources>
            <ts:BarlineSegmentTemplateSelector x:Key="BarlineSelector"/>
        </DataTemplate.Resources>
        <ItemsControl ItemsSource="{Binding Segments}" ItemTemplateSelector="{StaticResource BarlineSelector}">

        </ItemsControl>
    </DataTemplate>
</ResourceDictionary>